package com.bfxy.common.protobuf;

import com.google.protobuf.GeneratedMessageV3;
import lombok.Data;


/**
 * 通用的返回结果包装类
 * @param <T>
 */
@Data
public class Result <T extends GeneratedMessageV3>{

    private MessageModule.ResultType resultType;

    private T content;


    public static <T extends GeneratedMessageV3> Result<T> success(){
        Result<T> result=new Result<T>();
        result.resultType=MessageModule.ResultType.SUCCESS;
        return result;
    }

    public static <T extends GeneratedMessageV3> Result<T> success(T content){
        Result<T> result=new Result<T>();
        result.resultType=MessageModule.ResultType.SUCCESS;
        result.content=content;
        return result;
    }

    public static <T extends GeneratedMessageV3> Result<T> failure(){
        Result<T> result=new Result<T>();
        result.resultType=MessageModule.ResultType.FAILTURE;
        return result;
    }

    public static <T extends GeneratedMessageV3> Result<T> failure(T content){
        Result<T> result=new Result<T>();
        result.resultType=MessageModule.ResultType.FAILTURE;
        result.content=content;
        return result;
    }
}
